<?php

   require_once('MySQLdatabase.php');
    
  class member extends MySQLdatabase{
      
       public function insertPic($file,$username){
        $this->connectDatabase();
         
         $sQuery = "UPDATE member SET Picture=$file WHERE username ='$username'";
         
        $result = mysql_query($sQuery); //EXECUTE SQL
    }
    
    
    
     public function addMember($fname,$lname,$mi,$gender){
        $this->connectDatabase();
         
        $sQuery = "INSERT INTO member(firstname,lastname,username,password)
                    VALUES ('$fname','$lname','$mi','$gender')";
         
        $result = mysql_query($sQuery); //EXECUTE SQL
    }
    

  public function checkUserAccount($username,$password){
        $this->connectDatabase();
        $sQuery = "SELECT * FROM member WHERE username='$username' and password='$password';";
        $result = mysql_query($sQuery);
        $row = mysql_fetch_row($result);
        if(!isset($row)){
            $row = null;
        }       
        return $row;
    }
    
    public function displayAccount($username){
        $this->connectDatabase();
        $sQuery = "SELECT * FROM member WHERE username='$username';";
        $result = mysql_query($sQuery);
        $row = mysql_fetch_row($result);
        if(!isset($row)){
            $row = null;
        }       
        return $row;
    }
    
    

  }
   class comment extends MySQLdatabase{
  
   public function displayComment($name){
        $this->connectDatabase();
        $sQuery = "SELECT comment_id FROM image WHERE comment_id='$name';";
        $result = mysql_query($sQuery);
        $row = mysql_fetch_row($result);
        if(!isset($row)){
            $row = null;
        }       
        return $row;
    }

   }
  
  
  class image extends MySQLdatabase{
    
    public function addImage($filename){
        $this->connectDatabase();
         
        $sQuery = "INSERT INTO image(image_name)
                    VALUES ('$filename')";
         
        $result = mysql_query($sQuery); //EXECUTE SQL
    }
     public function checkImage($filename){
        $this->connectDatabase();
        $sQuery = "SELECT * FROM image WHERE image_name='$filename'";
        $result = mysql_query($sQuery);
        $row = mysql_fetch_row($result);
        if(!isset($row)){
            $row = null;
        }       
        return $row;
    }
    
      public function choose(){
        $this->connectDatabase();
        $sQuery = "SELECT image_name FROM image ORDER BY image_name ASC";
        $result = mysql_query($sQuery);
        $ctr = 0;
         
        while ($row = mysql_fetch_assoc($result)) {
            $image[$ctr]= $row['image_name'];
            $ctr++;
            
        }
        return $image;
    }
       
  }

?>